<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>星球银河 - 留言中心</title>
    <link href="/public/index/css/bootstrap.min.css" rel="stylesheet">
    <link href="/public/index/css/font-awesome.min.css" rel="stylesheet">
    <link href="/public/index/css/toastr.min.css" rel="stylesheet">
    <link href="/public/index/css/jquery.gritter.css" rel="stylesheet">
    <link href="/public/index/css/animate.css" rel="stylesheet">
    <link href="/public/index/css/style.css" rel="stylesheet">
    <link href="/public/index/css/loaders.css" rel="stylesheet">
    <link href="/public/index/css/all.css" rel="stylesheet">
    <link href="/public/index/css/bootstrap-table.min.css" rel="stylesheet">
    <link href="/public/index/css/ladda-themeless.min.css" rel="stylesheet">
    <style type="text/css">body{background-size:30%;}.fixed-table-pagination{margin-left:20px;margin-right:12px;}@-webkit-keyframes bell{0%{filter:grayscale(0) blur(3px);color:#ec7063;}10%{filter:grayscale(0) blur(2px);color:#ec7063;}30%{filter:grayscale(0) blur(1px);color:#ec7063;}100%{filter:grayscale(0) blur(0px);color:#ec7063;}}#bell{}.nav-fix{display:inline-block!important;font-size:14px;}</style>
</head>
<body>
<div id="wrapper">
    {include file="Include/left" /}
    <div id="page-wrapper" class="gray-bg">
        {include file="Include/right" /}
        <link href="/public/index/css/sweetalert.css" rel="stylesheet">
        <div class="wrapper wrapper-content animated fadeInUp">
            <style type="text/css">.form-control[disabled],.form-control[readonly],fieldset[disabled] .form-control{background-color:#fff;opacity:1;}</style>
            <style type="text/css">input[type=checkbox],input[type=radio]{margin:4px 0 0 !important;margin-top:1px 9;line-height:normal;width:26px;height:26px}</style>
            <div class="row animated fadeInUp" id="list">
                <div class="col-lg-12">
                    <div class="ibox-title">
                        <h5>留言列表</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user"></ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div id="toolbar" class="btn-group">
                        <button id="btn_delete" type="button" class="btn btn-danger" style="margin-right: 10px">
                            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 删除选中项
                        </button>
                        <a href="{:Url('message/message_add')}">
                            <button id="btn_add" type="button" class="btn btn-primary" onclick="add();">
                                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 添加留言
                            </button>
                        </a>
                    </div>
                        <table id="table" class="table-responsive">
                            {volist name="data" id="val" key="k"}
                            <tr>
                                <td value="{$val.id}"></td>
                                <td>{$val.id}</td>
                                <td>{$val.title}</td>
                                <td>{$val.content}</td>
                                <td>{$val.create_time}</td>
                                <td>{$val.back_content}</td>
                                <td>{$val.back_time}</td>
                                <td>{$val.status}</td>
                                <td>
                                    <a href="{:Url('message/message_see',['id'=>$val['id']])}">
                                        <button  type="button" class="btn btn-primary" >
                                            查看
                                        </button>
                                    </a>
                                </td>
                            </tr>
                            {/volist}
                        </table>
                    </div>
                </div>
            </div>
        </div>
        {include file="Include/foot" /}
<script type="text/javascript">
    $(document).ready(function(){
        function getIdSelections(){
        return $.map($('#table').bootstrapTable('getSelections'),function(row) {return row.id;});
    }
    $('#btn_delete').on('click',function(){
        var checked =getIdSelections();
        if(checked==''){}
        else{
            swal({
                title:"删除所有选中的留言吗?",text:"该操作无法撤回，请谨慎操作！",
                type:"warning",showCancelButton:true,confirmButtonColor:"#DD6B55",
                confirmButtonText:"确认删除",cancelButtonText:"取消",closeOnConfirm:false
            },
                function () {
                $.ajax({
                    type:"POST",
                    url:'{:url("Message/del")}',
                    dataType:'json',
                    cache:false,
                    data:{data:checked},
                    success:function(data) {
                        if(data == null) {
                            swal("响应超时!","","error");
                            return;
                        }
                        swal("删除成功!","","success");
                            $("button[name='refresh']").click();
                        },
                    error:function(xhr,status,error) {
                        console.log(xhr);console.log(status);console.log(error);
                        swal("响应超时!","","error");
                    }
                });
            });
        }
    });

    $.extend($.fn.bootstrapTable.defaults,$.fn.bootstrapTable.locales['zh-CN']);
    $('#table').bootstrapTable({
        url:"Message/message",
        dataType:"json",
        cache:false,
        method:"get",
        striped:true,
        pagination:true,
        singleSelect:false,
        search:true,
        showToggle:true,
        showRefresh:true,
        trimOnSearch:false,
        queryParamsType:'limit',
        showPaginationSwitch:true,
        toolbar:'#toolbar',
        showColumns:true,
        uniquId:'uid',
        sidePagination:"client",
        columns:[
            {checkbox:true,},
            {title:'留言ID',field:'id',align:'center',valign:'middle'},
            {title:'标题',field:'title',align:'center',valign:'middle',formatter:function indexFormatter(value,row,index) {return value.replace(/<[^>]+>/g,"")}},
            {title:'我的留言',field:'content',align:'center',valign:'middle',formatter:function indexFormatter(value,row,index) {return value.replace(/<[^>]+>/g,"")}},
            {title:'留言时间',field:'created_at',align:'center',valign:'middle',},
            {title:'官方回复',field:'reply',align:'center',valign:'middle',formatter:function indexFormatter(value,row,index) {if(value==null){value ='-';}if(value.length>10){value =value.substr(0,10)+'&nbsp; ...';}return value.replace(/<[^>]+>/g,"")}},
            {title:'回复时间',field:'updated_at',align:'center',valign:'middle',},
            {title:'状态',field:'status',align:'center',valign:'middle',formatter:function indexFormatter(value,row,index) {if(value==0){return '未处理'}if(value==1){return '已处理'}}},
            {title:'操作',field:'do',align:'center'}
        ]
    });
    });
</script>
<script type="text/javascript">
    $(document).ready(
        function(){
            $('#message').parent().parent().addClass('active');
            $('#message').parent().addClass('in');
            $('#message').addClass('active');
        });
</script>
</body>
</html>
